package com.ccys.cms.controller.administrator;

import com.ccys.cms.service.administrator.TblSupportTabTitleWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.administrator.TblSupportTabTitleDTO;
import com.ccys.db.entity.TblSupportTabTitle;
import com.ccys.db.vo.administrator.TblSupportTabTitleDetailWebVO;
import com.ccys.db.vo.administrator.TblSupportTabTitleWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "系统设置-support management 支援管理-content Support list")
@RequestMapping("administrator")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT}) // 开启跨域访问允许
@SuppressWarnings("unchecked")
public class SupportTabTitleWebController {

    @Autowired
    private TblSupportTabTitleWebService tblSupportTabTitleWebService;

    @GetMapping("supportTabTitle")
    @ApiOperation("获取列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "supportTabTitleName", value = "supportTabTitleName", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "status", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleCountries", value = "国家ID", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleSpecialisations", value = "专科ID", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabId", value = "supportTabTitleName", required = false, dataType = "string", paramType = "query"),

            @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = TblSupportTabTitleWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblSupportTabTitleDTO dto) {
        return this.tblSupportTabTitleWebService.listObjectsCms(request, response, dto);
    }

    @GetMapping("supportTabTitle/detail")
    @ApiOperation("查询详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = TblSupportTabTitleDetailWebVO.class)
    })
    public ResponseResult getTblSupportTabTitleDetail(@ApiIgnore TblSupportTabTitleDTO dto) {
        Kit.allParamValid(dto, "id");
        return this.tblSupportTabTitleWebService.getTblSupportTabTitleDetail(dto);
    }


    @PostMapping("supportTabTitle")
    @ApiOperation("添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "status", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabId", value = "supportTabId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleName", value = "supportTabTitleName", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleContent", value = "supportTabTitleContent", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleCountries", value = "0 代表全部，多个国家以英文逗号,隔开 历史数据存在 | 分割的情况", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleSpecialisations", value = "-1 代表全部,多个以英文逗号隔开,历史数据存在 | 分割的情况", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult save(@ApiIgnore TblSupportTabTitle entity) {
        entity.setId(null);
        return this.tblSupportTabTitleWebService.change(entity);
    }


    @PutMapping("supportTabTitle")
    @ApiOperation("编辑")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "status", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabId", value = "supportTabId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleName", value = "supportTabTitleName", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleContent", value = "supportTabTitleContent", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleCountries", value = "0 代表全部，多个国家以英文逗号,隔开 历史数据存在 | 分割的情况", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "supportTabTitleSpecialisations", value = "-1 代表全部,多个以英文逗号隔开,历史数据存在 | 分割的情况", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(@ApiIgnore TblSupportTabTitle entity) {
        Kit.allParamValid(entity, "id");
        return this.tblSupportTabTitleWebService.change(entity);
    }


    @DeleteMapping("supportTabTitle")
    @ApiOperation("删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult delete(TblSupportTabTitle dto) {
        Kit.allParamValid(dto, "id");
        return this.tblSupportTabTitleWebService.delete(dto);
    }

}